﻿using AutojsController.Services;
using Avalonia.Collections;
using Avalonia.Controls;
using Avalonia.Controls.Notifications;
using ReactiveUI;
using SukiUI.Dialogs;
using SukiUI.Toasts;
using System;
using System.Collections.Generic;
using System.Linq;
using Tmds.DBus.Protocol;

namespace AutojsController.ViewModels
{
    public class MainWindowViewModel : ReactiveObject
    {
        public IAvaloniaReadOnlyList<ViewModelBase> ViewModels { get; }
        public PageNavigationService NavigationService { get; }
        public ISukiToastManager ToastManager { get; }
        public ISukiDialogManager DialogManager { get; }

        private ViewModelBase? _activePage;
        public ViewModelBase? ActivePage
        {
            get => _activePage;
            set => this.RaiseAndSetIfChanged(ref _activePage, value);
        }
        public MainWindowViewModel(IEnumerable<ViewModelBase> vms, PageNavigationService nav, ISukiToastManager toast, ISukiDialogManager dialog)
        {
            ViewModels = new AvaloniaList<ViewModelBase>(vms.OrderBy(x=>x.Index));
            NavigationService = nav;
            ToastManager = toast;
            DialogManager = dialog;
        }
    }
}
